<?php
/**
 * 
 */
class Tag extends AppModel {
  
	var $name = 'Tag';
  var $displayField = 'name';
  
	var $validate = array(
			'name' => array(
        'notempty' => array(
          'rule' => array('notempty'),
          //'message' => 'Your custom message here',
          //'allowEmpty' => false,
          //'required' => false,
          //'last' => false, // Stop validation after this rule
          //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
       'maxlength' => array(
          'rule' => array('maxlength', 40),
          'message' => 'Maximum length of this field is 40.',
          //'allowEmpty' => false,
          //'required' => false,
          //'last' => false, // Stop validation after this rule
          //'on' => 'create', // Limit validation to 'create' or 'update' operations
        ),
        'isUnique' => array(
            'rule' => 'isUnique',        
            'message' => 'This value has already been taken. Please choose something unique.'
        )          
    )
	);
	//The Associations below have been created with all possible keys, those that are not needed can be removed

//	var $hasAndBelongsToMany = array(
//		'Job' => array(
//			'className' => 'Job',
//			'joinTable' => 'jobs_tags',
//			'foreignKey' => 'tag_id',
//			'associationForeignKey' => 'job_id',
//			'unique' => true,
//			'conditions' => '',
//			'fields' => '',
//			'order' => '',
//			'limit' => '',
//			'offset' => '',
//			'finderQuery' => '',
//			'deleteQuery' => '',
//			'insertQuery' => ''
//		)
//	);

  var $hasMany = array(  
    // Trying to make the HABTM 'join table' a regular association instead by making it a 'membership' table.
    //      Job hasMany JobsTag
    //      Tag hasMany JobsTag
    //      JobsTag belongsTo Job,Tag
    'JobsTag' => array(
        'className' => 'JobsTag',
        'foreignKey' => 'tag_id',
        'dependent'    => true,   // When a tag gets deleted, also delete it's job membership
        //'dependent' => false,
        'conditions' => '',
        'fields' => '',
        'order' => '',
        'limit' => '',
        'offset' => '',
        'exclusive' => '',
        'finderQuery' => '',
        'counterQuery' => ''
		)
  );
  
}
